const express = require('express');

const uploadController = require('../controller/upload-controller');

const router = express.Router();

/**
 * @openapi
 * /upload/images:
 *   post:
 *     tags:
 *       - 上传文件
 *     description: 上传整个文件
 */
router.post('/images', uploadController.multerMiddleware.single('uploaded_file'), uploadController.multerHandler);

/**
 * @openapi
 * /upload/slices:
 *   post:
 *     tags:
 *       - 上传文件切片
 *     description: 上传切片
 */
router.post('/slices', uploadController.multipartMiddleware, uploadController.multipartyHandler);

/**
 * @openapi
 * /merge/:md5/:name:
 *   get:
 *     tags:
 *       - 合并文件
 *     description: 合并文件切片
 */
router.get(
  '/merge/:md5/:name',
  uploadController.findMergeHandler,
  uploadController.findTargetHandler,
  uploadController.mergeHandler,
);

module.exports = router;
